;+
; NAME:
;       DISPLAY_MW
;
; PURPOSE:
;       Plot Galactocentic positions of sources atop the pretty
;       Spitzer artist's rendering.
;
; CATEGORY:
;       Plotting
;
; CALLING SEQUENCE:
;       DISPLAY_MW
;
; INPUTS:
;       NONE
;
; OPTIONAL INPUTS:
;       NONE
;
; KEYWORD PARAMETERS:
;       NONE
;
; OUTPUTS:
;       NONE
;
; OPTIONAL OUTPUTS:
;       NONE
;
; COMMON BLOCKS:
;       NONE
;
; MODIFICATION HISTORY:
;
;       Created:  11/21/12, TPEB -- Initial version.
;       Modified: 12/20/12, TPEB -- Turned into a PRO and added
;                                   (simple) documentation for filing
;                                   in the repository.
;       Modified: 03/11/13, TPEB -- Moved Bar circle to 4.0 kpc a la
;                                   Benjamin:2005.
;       Modified: 03/18/13, TPEB -- Added B&W version for published
;                                   paper to avoid paying $$$.
;
;-

PRO DISPLAY_MW
  
     ;; Add to the plot our stuff...
     mw = omni_read_conffile('./conffiles/galactic_params.conf')
     dpdfs = omni_read_conffile('./conffiles/dpdf_params.conf')
     d = dindgen(dpdfs.NBINS)*dpdfs.BINSIZE + dpdfs.BINSTART
     R0 = MW.R0
     
     restore,'./local/BGPS_V1_pvec.sav',/ver
     restore,'./local/BGPS_V1_emaf.sav',/ver
     n = n_elements(emaf)
     eind = where(constrain.emaf)
     pvec = pvec[eind]
     constrain = constrain[eind]
     
     pvec.stat.duse /= 1.d3
     
     ;; Restrict consideration to "well-constrained" sources...
     cind      = where(constrain.post,n)
     emaf      = emaf[cind]
     pvec      = pvec[cind]
     constrain = constrain[cind]
     
  bw=[0,1]
  suf=['','_bw']
  
  ;; Run for color & BW
  FOR colt=0,1 DO BEGIN
     
     
  ;; Make the plot for both the annotated image and the blank image
  outfn = ['annot','blank']
  infn  = './emaf_paper/MW_Spitzer_'+['A','B']+'_10kpc'+suf[colt]+'.png'
  
  FOR jj=0,1 DO BEGIN
     
     myps,'./emaf_paper/plots/MW_plot_'+outfn[jj]+suf[colt]+'.eps',$
          xsize=3.1,ysize=3.1,BW=bw[colt]
     
     ;; The Spitzer Images have 134.379 pix/kpc in the 5600x5600 version
     ;; We're using the 1500x1500 version:
     pixper = 134.379 * 1500./5600.
     ;; Also, cropping to 33/56*1500 = 884 pixels  (Down to 680 pix now)
     crop = 3300./5600.*1500. * 680./884.
     width = crop / pixper
     
     ;; Include a fudge-factor for scaling to properly place sun at 
     ;;   8.5 kpc, edge = width/2.
     edge = (width/2.)*1.065
     range = [-edge,edge]
     
     !x.thick=3
     !y.thick=3

     cs = 0.7
     
     ;; Plot the image using cgImage
     cgImage,image,filename=infn[jj],/keep_aspect,charsize=cs,$
             xtit='Galactocentric Position [kpc]',xrange=range,yrange=range,$
             ytit='Galactocentric Position [kpc]',color='Black',/interpolate,$
             background='White',/axes,position=[0.14,0.09,0.98,0.99]
     
     
     ;; Solar Circle and Tangent Circles
     ells = findgen(1001)/1.e3*180.
     scl = findgen(1001)/1.e3*360.
     xells = -(R0/1.d3 * cos(ells*!dtor)) *  sin(ells * !dtor)
     yells = + (R0/1.d3 * cos(ells*!dtor)) * cos(ells * !dtor) - R0/1.d3
     xsc   = -R0/1.d3 * cos(scl * !dtor)
     ysc   = -R0/1.d3 * sin(scl * !dtor)
     xbar  = -4.0 * cos(scl * !dtor)
     ybar  = -4.0 * sin(scl * !dtor)
     cgOplot,xells,yells,linestyle=1,color='Black',thick=2
     cgOplot,xsc,ysc,linestyle=1,color='Black',thick=2
     cgOplot,xbar,ybar,linestyle=2,color='Blk7',thick=2
     
     ;; l=30 line (through end of the Bar)
     cgPlots,0,-R0/1.d3
     cgPlots,-R0/1.d3*cos(30*!dtor),R0/1.d3*sin(30*!dtor),/cont,linestyle=2,$
             thick=3,color='BLK5'
     
     ;; Make x,y position for plotting
     x = -pvec.stat.duse[0] * sin(emaf.l*!dtor)
     y = -R0/1.d3 + pvec.stat.duse[0] * cos(emaf.l*!dtor)
     
     ;; Plot all the BGPS Objects!!!1!
     cgPlots,x,y,psym=16,symsize=0.2,color='Black'
     
     ;; Sun and Galactic Center
     cgPlots,0,0,psym=7,color='BLK6',symsize=0.6,thick=3
     cgPlots,0,-R0/1.d3,psym=7,color='BLK6',symsize=0.6,thick=3
     cgText,0.1,0.4,'GC',charsize=cs/2.,color='Black'
     cgText,0.1,-8.1,'Sun',charsize=cs/2.,color='Black'
     
     ;; Label spiral arms, as desired...
     cgText,-5.0,0.9,'Sagittarius Arm',charsize=cs*0.85/2.,$
            alignment=0.5,orientation=60.,color='Black'
     cgText,-5.7,3.5,'Perseus Arm',charsize=cs/2.*1.2,$
            alignment=0.5,orientation=40.,color='Black'
     ;; cgText,-7.5,5.5,'Outer Arm?',charsize=0.7,$
     ;;        alignment=0.5,orientation=30.,color='Red'
     cgText,-1.1,-2.6,'End of Bar?',charsize=cs*0.85/2.,$
            alignment=0.5,orientation=0.,color='Black'
     cgText,+1.0,-5.8,'Sct-Cen Arm',charsize=cs/2.,$
            alignment=0.5,orientation=0.,color='Black'
     
     myps,/done
     
  ENDFOR
  
ENDFOR
END
